
//类模板的构造函数不能使用参数列表


#include <iostream>
#include <cstring>
using namespace std;

template <class t1, class t2>
class person
{
public:
    t1 age;
    t2 name;

    //  person(t1 m_age, t2 m_name) : (age)m_age, (name)m_name {} //类模板的构造函数不能使用参数列表
    person(t1 m_age, t2 m_name)
    {
        age = m_age;
        name = m_name;
    }

    void display()
    {
        cout << age << name << endl;
    }
};

int main()
{
    person<int, string> p1(23, "xiao_bai");
    p1.display();
}
//类模板可以设置默认参数
#include <iostream>
#include <cstring>
using namespace std;

template <class t1 = int, class t2 = string> //类模板可以设置默认参数
class person
{
public:
    t1 age;
    t2 name;

    //  person(t1 m_age, t2 m_name) : (age)m_age, (name)m_name {} 类模板不能使用参数列表
    person(t1 m_age, t2 m_name)
    {
        age = m_age;
        name = m_name;
    }

    void display()
    {
        cout << age << name << endl;
    }
};

int main()
{
    person<int, string> p1(23, "xiao_bai");
    p1.display();
}
//3 - 类模板不能像函数模板那样有自动类型推导
#include <iostream>
#include <cstring>
using namespace std;

template <class t1 = int, class t2 = string> //类模板可以设置默认参数
class person
{
public:
    t1 age;
    t2 name;

    //  person(t1 m_age, t2 m_name) : (age)m_age, (name)m_name {} 类模板不能使用参数列表
    person(t1 m_age, t2 m_name)
    {
        age = m_age;
        name = m_name;
    }

    void display()
    {
        cout << age << name << endl;
    }
};

int main()
{

    person p1(23, "xiao_bai"); //报错,类模板创建对象必须要指定对象类型
    p1.display();
}